﻿var status = 0;
var choice;
var scrolls = Array(
Array("", 1142176, 0),
Array("", 1142177, 0),
Array("", 1142178, 0),
Array("", 1142179, 0),
Array("", 1142184, 0),
Array("", 1142186, 0),
Array("", 1142187, 0),
Array("", 1142188, 0),
Array("", 1142189, 0),
Array("", 1142190, 0),
Array("", 1142191, 0),
Array("", 1142208, 0),
Array("", 1142209, 0),
Array("", 1142210, 0),
Array("", 1142211, 0),
Array("", 1142212, 0),
Array("", 1142213, 0),
Array("", 1142214, 0),
Array("", 1142215, 0),
Array("", 1142216, 0),
Array("", 1142217, 0),
Array("", 1142218, 0),
Array("", 1142219, 0),
Array("", 1142220, 0),
Array("", 1142226, 0),
Array("", 1142227, 0),
Array("", 1142228, 0),
Array("", 1142230, 0),
Array("", 1142231, 0),
Array("", 1142232, 0),
Array("", 1142233, 0),
Array("", 1142234, 0),
Array("", 1142235, 0),
Array("", 1142242, 0),
Array("", 1142243, 0),
Array("", 1142244, 0),
Array("", 1142245, 0),
Array("", 1142246, 0),
Array("", 1142249, 0),
Array("", 1142250, 0),
Array("", 1142254, 0),
Array("", 1142255, 0),
Array("", 1142256, 0),
Array("", 1142257, 0),
Array("", 1142258, 0),
Array("", 1142259, 0),
Array("", 1142260, 0),
Array("", 1142263, 0),
Array("", 1142264, 0),
Array("", 1142265, 0),
Array("", 1142266, 0),
Array("", 1142267, 0),
Array("", 1142268, 0),
Array("", 1142269, 0),
Array("", 1142270, 0),
Array("", 1142271, 0),
Array("", 1142272, 0),
Array("", 1142273, 0),
Array("", 1142274, 0),
Array("", 1142275, 0),
Array("", 1142276, 0),
Array("", 1142277, 0),
Array("", 1142278, 0),
Array("", 1142279, 0),
Array("", 1142280, 0),
Array("", 1142281, 0),
Array("", 1142282, 0),
Array("", 1142283, 0),
Array("", 1142286, 0),
Array("", 1142287, 0),
Array("", 1142288, 0),
Array("", 1142292, 0),
Array("", 1142293, 0),
Array("", 1142295, 0),
Array("", 1142296, 0),
Array("", 1142297, 0),
Array("", 1142298, 0),
Array("", 1142299, 0),
Array("", 1142300, 0),
Array("", 1142301, 0),
Array("", 1142304, 0),
Array("", 1142305, 0),
Array("", 1142306, 0),
Array("", 1142307, 0),
Array("", 1142308, 0),
Array("", 1142309, 0),
Array("", 1142310, 0),
Array("", 1142311, 0),
Array("", 1142312, 0),
Array("", 1142313, 0),
Array("", 1142314, 0),
Array("", 1142315, 0),
Array("", 1142316, 0),
Array("", 1142317, 0),
Array("", 1142318, 0),
Array("", 1142319, 0),
Array("", 1142320, 0),
Array("", 1142321, 0),
Array("", 1142328, 0),
Array("", 1142329, 0),
Array("", 1142334, 0),
Array("", 1142335, 0),
Array("", 1142336, 0),
Array("", 1142337, 0),
Array("", 1142338, 0),
Array("", 1142339, 0),
Array("", 1142340, 0),
Array("", 1142341, 0),
Array("", 1142342, 0),
Array("", 1142343, 0),
Array("", 1142344, 0),
Array("", 1142345, 0),
Array("", 1142346, 0),
Array("", 1142347, 0),
Array("", 1142348, 0),
Array("", 1142349, 0),
Array("", 1142350, 0),
Array("", 1142351, 0),
Array("", 1142352, 0),
Array("", 1142353, 0),
Array("", 1142354, 0),
Array("", 1142355, 0),
Array("", 1142356, 0),
Array("", 1142358, 0),
Array("", 1142359, 0),
Array("", 1142360, 0),
Array("", 1142362, 0),
Array("", 1142363, 0),
Array("", 1142367, 0),
Array("", 1142369, 0),
Array("", 1142371, 0),
Array("", 1142372, 0),
Array("", 1142373, 0),
Array("", 1142374, 0),
Array("", 1142375, 0),
Array("", 1142376, 0),
Array("", 1142377, 0),
Array("", 1142378, 0),
Array("", 1142379, 0),
Array("", 1142384, 0),
Array("", 1142385, 0),
Array("", 1142386, 0),
Array("", 1142389, 0),
Array("", 1142390, 0),
Array("", 1142391, 0),
Array("", 1142392, 0),
Array("", 1142393, 0),
Array("", 1142394, 0),
Array("", 1142395, 0),
Array("", 1142396, 0),
Array("", 1142397, 0),
Array("", 1142398, 0),
Array("", 1142399, 0),
Array("", 1142400, 0),
Array("", 1142401, 0),
Array("", 1142402, 0),
Array("", 1142403, 0),
Array("", 1142404, 0),
Array("", 1142406, 0),
Array("", 1142407, 0),
Array("", 1142408, 0),
Array("", 1142409, 0),
Array("", 1142440, 0),
Array("", 1142441, 0),
Array("", 1142442, 0),
Array("", 1142443, 0),
Array("", 1142444, 0),
Array("", 1142445, 0),
Array("", 1142446, 0),
Array("", 1142447, 0),
Array("", 1142448, 0),
Array("", 1142457, 0),
Array("", 1142472, 0),
Array("", 1142477, 0),
Array("", 1142478, 0),
Array("", 1142479, 0),
Array("", 1142480, 0),
Array("", 1142481, 0),
Array("", 1142482, 0),
Array("", 1142483, 0),
Array("", 1142484, 0),
Array("", 1142485, 0),
Array("", 1142486, 0),
Array("", 1142487, 0),
Array("", 1142488, 0),
Array("", 1142495, 0),
Array("", 1142496, 0),
Array("", 1142497, 0),
Array("", 1142498, 0),
Array("", 1142499, 0),
Array("", 1142500, 0),
Array("", 1142501, 0),
Array("", 1142502, 0),
Array("", 1142503, 0),
Array("", 1142504, 0),
Array("", 1142505, 0),
Array("", 1142511, 0),
Array("", 1142512, 0),
Array("", 1142514, 0),
Array("", 1142515, 0),
Array("", 1142516, 0),
Array("", 1142520, 0),
Array("", 1142531, 0),
Array("", 1142532, 0),
Array("", 1142533, 0),
Array("", 1142536, 0),
Array("", 1142538, 0)
);

function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == -1) cm.dispose();
    else {
        if (status == 0 && mode == 0) {
            cm.dispose();
            return;
        } else if (status >= 1 && mode == 0) {
            cm.sendOk("好吧，欢迎下次继续光临！.");
            cm.dispose();
            return;
        }
        if (mode == 1) status++;
        else status--;

        if (status == 0) {
            choices = "\r\n兔兔币余额：#r" + cm.getHyPay(1) + "#k个 (#r买后不支持退货哟亲#k)";
            for (var i = 0; i < scrolls.length; i++) {
                choices += "\r\n#L" + i + "##v" + scrolls[i][1] + "##z" + scrolls[i][1] + "#　#d需要#r" + scrolls[i][2] + "#d兔兔币#k#l";
            }
            cm.sendSimpleS("欢迎来到配件3店,你想买我们商店的物品么?请选择吧：." + choices,2);
        } else if (status == 1) {
            cm.sendYesNo("你确定需要购买#v" + scrolls[selection][1] + "##t" + scrolls[selection][1] + "#?");
		choice = selection;
        } else if (status == 2) {
            var money = scrolls[choice][2];
            if (cm.getHyPay(1) < money) {
                cm.sendOk("抱歉，你没足够的兔兔币！");
                cm.dispose();
            } else {
                cm.addHyPay(money);
                cm.gainItem(scrolls[choice][1], 1);
                cm.sendOk("购买成功.");
                cm.dispose();
            }
        }
    }
}